package com.hulk.mq;

/**
 * 功能概要：消息产生,提交到队列中去 
 * @author CUIJIAJUN
 * @date   2017年1月6日
 * 
 */
import javax.annotation.Resource;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:MessageProducer_fanout.xml" })
public class MessageProducer_fanout {

	@Resource
	private RabbitTemplate rabbitTemplate;

	@Test
	public void testRabbitMq() throws Exception {
		// 往名字为leo.pay.fanout.exchange的路由里面发送数据，客户端中只要是与该路由绑定在一起的队列都会收到相关消息，这类似全频广播，发送端不管队列是谁，都由客户端自己去绑定，谁需要数据谁去绑定自己的处理队列。
		for (int i = 1; i <= 10; i++) {
			String str = "hello" + i;
			rabbitTemplate.send("leo.pay.topic.exchange","test321.hello.test123", new Message(str.getBytes(),new MessageProperties()));
			System.out.println("SUCCESS=" + i);
		}
	}
}